package com.hl.sfzy.service;

import com.hl.sfzy.entity.LogonUser;
import com.hl.sfzy.mapper.LogonUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: sfzy
 * @description: 更换绑定手机
 * @author: Syy
 * @create: 2024-09-10 11:29
 **/
@Service
public class ReplaceBindPhoneService {
    @Autowired
    private LogonUserMapper logonUserMapper;

    //更换绑定手机业务1
    public LogonUser selectByUsername(String username) {
        LogonUser logonUser = logonUserMapper.findLogonUserByUsername(username);
        if (logonUser != null && logonUser.getRole() == 3) {
            return logonUser;
        } else return null;
    }

    //更换绑定手机业务2
    //先根据手机号查询用户
    public List<LogonUser> selectByPhone(String phone) {
        return logonUserMapper.findLogonUserByPhone1(phone);
    }

    //根据id修改用户手机号实现更换绑定手机
    public int replaceBindPhone(String id, String phone) {
        return logonUserMapper.updateByPrimaryKeySelective(id, phone);
    }
}
